1 <<?php
2 session_start();
3 if(isset($_SESSION['user']))
4 {
5
6 }
7 else{
8 echo"<script>location.href='login.html'</script>";
9 }
10 ?>
11 !doctype html>
12 <html>
13 <head>
14 <title>
15 Salesdetails
16 </title>
17 <style>
18
19 body {
20 margin: 0;
21 font-family: Arial, Helvetica, sans-serif;
22 background: #484848;
23 }
24 .topnav {
25 overflow: hidden;
26 background-color: rgba(249, 105, 14, 1);
27 height: 70px;
28 border: 3px solid #e69500;
29 }
30
31 .topnav a {
32 float: left;
33 color: #f2f2f2;
34 text-align: center;
35 padding: 14px 16px;
36 text-decoration: none;
37 font-size: 35px;
38 font-weight: bold;
39 }
40
41 .topnav-right {
42 float: right;
43 }
44
45 fieldset { max-width: 450px;
46 background: #FAFAFA;
47 padding: 30px;
48 margin: 50px auto;
49 box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
50 border-radius: 10px;
51 border: 6px solid rgba(249, 105, 14, 1);
52
53
54 }
55
56 legend {
57 padding: 0.2em 0.5em;
58 border:2px solid rgba(249, 105, 14, 1);
59 color:green;
60 font-size:90%;
61 text-align:center;
62 }
63 </style>
64 </head>
65 <body>
66 <div class="topnav">
67 <a class="active" href="home.html"><img src="ic_add_pet.png"></a>
68 <a href="sales.php">Sales details</a>
69 <div class="topnav-right">
70 <a href="logout.php">logout</a>
71 </div>
72 </div>
73 <form>
74 <button type="submit" formaction="soldpets.php" style="margin:15px;height: 30px;width: 100px;
75 border-radius:15px;
76 border: 3px solid #e69500;background-color: rgba(249, 105, 14, 1);color:#f2f2f2;font-size:15px;cursor:pointer;">Back</button>
77 </form>
78 <form method="post" action="soldptadd.php">
79 <fieldset>
80 <input type="text" name="id" placeholder="Enter sales details id" style="width:100%;height:30px;
81 border: 2px solid rgba(249, 105, 14, 1); border-radius:5px; background:transparent;" required>
82 <br><br>
83 <input type="text" name="pp" placeholder="Enter pet id" style="width:100%;height:30px;
84 border: 2px solid rgba(249, 105, 14, 1); border-radius:5px; background:transparent;" required>
85 <br><br>
86 <input type="submit" name="submit" value="ADD" style="width:100%;height:30px;
87 border: 2px solid rgba(249, 105, 14, 1); border-radius:5px; cursor:pointer;background-color: rgba(249, 105, 14, 1)"> 
88 </fieldset>
89 </form>
90 </body>
91 </html>
92 <?php
93 if(isset($_POST["submit"]))
94 {
95 // define variables and set to empty values
96 $servername = "localhost";
97 $username = "root";
98 $password = "";
99 $dbname = "Petshop_management";
100
101 // Create connection
102 $conn = new mysqli($servername, $username, $password, $dbname);
103 // Check connection
104 if ($conn->connect_error) {
105 die("Connection failed: " . $conn->connect_error);
106 }
107 //echo " CONNECTION ESTABLISHED \r\n";
108 //echo " INSERTION IN PROCESS";
109 $id = $_POST["id"];
110 $pet_id = $_POST["pp"];
111
112
113
114
115 $sql = "INSERT INTO sold_pets( sd_id,pet_id)
116 VALUES ('$id','$pet_id')";
117 if ($conn->query($sql) == TRUE) {
118 echo'<div>
119 <h1 style="color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">New record of sales_id='
120 .$id.'and pet_id='.$pet_id. ' inserted successfully</h1>
121 </div>';
122 $conn->query("call calculations_for_pets('$pet_id','$id')");
123 } else {
124 echo "Error: " . $sql . "<br>" . $conn->error;
125 }
126
127 $conn->close();
128 }
129
130 ?>